package com.brillilab.service.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 获取步骤中试剂UUID
 * @author lj
 *
 */
public class ReagentUuidsUtil {

	public static List<String> getReagentUuids(String content){
	        Pattern pattern = Pattern.compile("(#\\$\\{\\[reagent\\]<.*?>\\}\\$#)");
	        Matcher matcher=pattern.matcher(content);
	        List<String> uuids = new ArrayList<>();
	        
	        Pattern pattern2 = Pattern.compile("([0-9a-zA-Z]{32})");
	        while (matcher.find()){
	            String group=matcher.group();    
	            Matcher matcher2 = pattern2.matcher(group);
	            if(matcher2.find()) {
	            	String uuid = matcher2.group();
	            	uuids.add(uuid);
	            }
	        }
	        return uuids;
	    }
	
	public static String removeReagentUuids(String content){
		Pattern pattern = Pattern.compile("(#\\$\\{\\[reagent\\]<.*?>\\}\\$#)");
		Matcher matcher=pattern.matcher(content);
		return matcher.replaceAll("");
	}
}
